<?php
require_once 'Junction/Db/Exception.php';
require_once 'Junction/Db/Adapter.php';
require_once 'Junction/Libs/creole/Creole.php';

class Junction_Db_Creole_Adapter implements Junction_Db_Adapter {

	private $_conn;
	
	public function __construct() {
		
	}

	public function connectTo(array $dsn) {
		try {
			$creoleDSN = array('phptype' => $dsn['db_driver'],
	             'hostspec' => $dsn['db_host'],
	             'username' => $dsn['db_user'],
	             'password' => $dsn['db_pass'],
	             'database' => $dsn['db_name']);
             $this->_conn = Creole::getConnection($creoleDSN);
		} catch (SQLException $e) {
			throw new Junction_Db_Exception($e->getMessage());
		}
	}

	/**
	 * Fetch the adapter's DAO.
	 *
	 * @return Creole_Connection
	 */
	public function getConnection() {
		return $this->_conn;
	}
}
?>